<!DOCTYPE html>
<html><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <title></title>
    <meta charset="UTF-8">
   <link rel="stylesheet" type="text/css" href="__PUBLIC__/Admin/css/bootstrap.css">
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/Admin/css/bootstrap-responsive.css">
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/Admin/css/style.css">
    <style type="text/css">
        body {
            padding-bottom: 40px;
        }
        .sidebar-nav {
            padding: 9px 0;
        }

        @media (max-width: 980px) {
            /* Enable use of floated navbar text */
            .navbar-text.pull-right {
                float: none;
                padding-left: 5px;
                padding-right: 5px;
            }
        }
        #bg{width:100%;height:100%;top:0px;left:0px;position:absolute;filter: Alpha(opacity=50);opacity:0; background:#000000; display:none;}
       #popbox{position:absolute;width:200px; height:200px; left:55%; top:60%; margin:-200px 0 0 -200px; display:none;}
    </style>
   
<script src="__PUBLIC__/Admin/js/b5m.js" charset="utf-8" id="b5mmain" type="text/javascript"></script>
<link type="text/css" href="__PUBLIC__/Admin/css/b5m-plugin.css" rel="stylesheet">
<link type="text/css" href="__PUBLIC__/Admin/css/b5m.css" rel="stylesheet">
</head>
<body>
<table class="table table-bordered table-hover definewidth m10">
   <tbody>  
      <!-- 主任管理开始 -->      
      <tr>
         <td>主任管理：</td>       
          <td style="text-align:left;">
<!--             <select name="zurenqu" id="zhurenqu">
               <option selected="selected" value="-1">请选择区</option>
               <volist name='bumen' id='r'>
                 <option value="{$r.did}">{$r.dname}</option>
               </volist>
           </select>
           <select name="zurenbumen" id="zhurenbumen">
              <option selected="selected" value="-1">请选择部门</option>
              <option value="1">一部</option>
              <option value="2">二部</option>
              <option value="3">三部</option>
           </select>
           <select name="zurenzu" id="zurenzu">
              <option selected="selected" value="-1">请选择组</option>
              <option value="1">一组</option>
              <option value="2">二组</option>
              <option value="3">三组</option>
           </select> -->
           <select name="zurendui" id="zhurendui">
              <option selected="selected" value="-1">请选择队</option>
              <option value="1">一队</option>
              <option value="2">二队</option>
              <option value="3">三队</option>
           </select> 

           <input placeholder="请输入员工的登录帐号" id="zhurenval">
           <input value="新增主任" onclick="addZhuren()" class="btn btn-primary" type="button"><font>(主任的登陆账号)</font>
         </td>
         <td style="text-align:left;">
             <select name="" id="deleteZhuRen">
              <option selected="selected" value="-1">小组主任</option>
              <volist name='zr' id='d'>
                 <option value="{$d.userid}">{$d.username}</option>
              </volist>
             </select>
            <input onclick="deleteZhuRen()" value="删除主任" class="btn btn-primary" type="button">
            
          </td>
      </tr>
      <!-- 主任管理结束 -->

    </tbody>
  </table>
   <a href="#" onclick="pupopen()"></a>
       <div id="bg"></div>
       <div id="popbox">
          <img src="__PUBLIC__/Admin/images/loading.gif">
          <a href="#"  onclick="pupclose()"></a>
      </div>
</body>
    <script type="text/javascript" src="__PUBLIC__/Admin/js/jquery.js"></script>
    <!--<script type="text/javascript" src="Js/jquery.sorted.js"></script>-->
    <script type="text/javascript" src="__PUBLIC__/Admin/js/bootstrap.js"></script>
    <script type="text/javascript" src="__PUBLIC__/Admin/js/ckform.js"></script>
    <script type="text/javascript" src="__PUBLIC__/Admin/js/common.js"></script>
    <script type="text/javascript">
     function pupopen(){
          document.getElementById("bg").style.display="block";
          document.getElementById("popbox").style.display="block" ; 
    }

    function pupclose(){
          document.getElementById("bg").style.display="none";
          document.getElementById("popbox").style.display="none" ;  
    }
</script>
    <script type="text/javascript">

        /************添加主任************/
        function addZhuren()
        {
          var quid = $("#zhurenqu").val();
          var bumenid = $("#zhurenbumen").val();
          var zuid = $('#zurenzu').val();
          var zurendui = $('#zhurendui').val();
          var zhuren = $('#zhurenval').val();
          if(quid == -1)
          {
            alert('请选择区');
            return false;
          }
          if(bumenid == -1){
            alert('请选择部门');
            return false;
          }
          if(zuid == -1)
          {
            alert('请选择组');
            return false;
          }
          if(zurendui == -1)
          {
            alert('请选择队');
            return false;
          }
          if(zhuren == '')
          {
            alert('请输入员工的登录帐号');
            return false;
          }
          var action = confirm("是否添加主任");
          if(action)
          {
            $.ajax({
            url:"{:U('Group/addZhuRen')}",
            type:"post",
            dataType:'json',
            data:{'quid':quid,'bumenid':bumenid,'zuid':zuid,'duiid':zurendui,'zhuren':zhuren},
            success:function(data)
            {
              if(data.ok == 3)
              {
                alert('没有该员工');
              }
              if(data.ok == 1)
              {
                alert('添加成功');
              }
              if(data.ok == 2)
              {
                alert('添加失败');
              }
              if(data.ok == 0)
              {
                alert('该成员已经是主任');
              }
            }
            })
          }
        }
        
        /***********************删除主任***************/
        function deleteZhuRen(){
            var userid=$("#deleteZhuRen").val();
            if(userid==-1){
                alert("请选择要删除的主任");
                return false;
            }
            var run = confirm("是否删除主任?");
            if(run){
                pupopen();
                 $.ajax({
                    type: 'POST',
                    url: "{:U('Group/delZhuRen')}",
                    data: {userid:userid},
                    dataType : "json", 
                    success: function(data) {
                        pupclose();
                        if(data.ok==1){
                            alert("删除成功");
                            $("#employeeid").val(-1);
                            window.location.reload();
                        }
                         if(data.ok==2){
                            alert("删除失败,请稍后重试");
                            $("#employeeid").val(-1);
                        }
                        if(data.ok==0){
                            alert("删除失败,没有此帐号！");
                            $("#employeeid").val(-1);
                         
                         }
                      }
                   })               
            }
        }
    </script>
</html>